﻿<cfsilent>
	<cfscript>

		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		response = structNew();
		structInsert(response, "success", false, true);
		
		examId = event.getArg("EXID");
		
		transaction {
			
			/* 加载考试任务 */
			/* 考试场次 */
			
			/* 保存考试时间安排 */
			
			/* 更新排考进度 */
			
			
			sql = "UPDATE t_examtask 
					SET wdidx = :examWeekDay, 
						cellidx = :cellIndex, 
						task_prog = '0' 
					WHERE task_exid = :examTaskId ";
			
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="examWeekDay", value="0", cfsqltype="cf_sql_char" );
			queryObj.addParam( name="cellIndex", value=0, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="examTaskId", value=examId, cfsqltype="cf_sql_char" );
			
			queryObj.execute( sql=sql );
			
			/* 数据密闭 */
			
			/* 如果已经保存了学生考试安排 则全部删除 */
		
			sql = "DELETE 
					FROM t_student_exam 
					WHERE task_exid = :taskExid ";
			
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="taskExid", value=examId, cfsqltype="cf_sql_char" );
			
			queryObj.execute( sql=sql );
			
			/* 如果已经保存了场地占用 则全部删除 */
		
			sql = "DELETE 
					FROM t_clsroom_timetable 
					WHERE crtime_id IN (
						SELECT crtime_id 
						FROM t_clsroom_forexam 
						WHERE task_exid = :taskExid )";
							
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="taskExid", value=examId, cfsqltype="cf_sql_char" );
			queryObj.execute( sql=sql );
			
			structInsert(response, "ExamID", examId, true);
			
			structInsert(response, "success", true, true);
						
		}

	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>